package br.com.gerador.component;

import java.awt.Color;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JPanel;

import br.com.gerador.icomponent.IGProperty;
import br.com.gerador.util.ColorHelper;

public class DivComponent extends GComponent {
	JPanel area;
	
	public DivComponent() {
		area = new JPanel();
		area.setBounds(0, 0, Short.MAX_VALUE, Short.MAX_VALUE);
		add(area);
	}
		
	public void backgroundColor(String value){
		area.setBackground(ColorHelper.parseColor(value, Color.BLUE));
		validateTree();
	}

	public void border(String value){
		String[] border = value.split(";");
		String color = null;
		Integer size = null;
		for(String s: border ){
			String[] prop = s.split(":");
			if( "color".equalsIgnoreCase(prop[0]) ){
				color = prop[1];
			}else if( "size".equalsIgnoreCase(prop[0]) ){
				size = Integer.parseInt(prop[1]);
			}
		}
		area.setBorder(BorderFactory.createLineBorder(ColorHelper.parseColor(color, Color.WHITE),size));
		validateTree();
	}
	
	String[][] propriedades = new String[][]{
		{"ID","","id"},
		{"Background-color","#FFFFFF","backgroundColor"},
		{"border","color:#000000;size:1","border"}
	};

	@Override
	public String[][] getPropriedades() {
		return propriedades;
	}

	@Override
	public void setPropriedades(String[][] values) {
		this.propriedades = values;
	}

}
